{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Gradiant Boosting Regression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.tree import DecisionTreeRegressor\n",
    "from sklearn.datasets import load_boston\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Load data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "boston=load_boston()\n",
    "n_samples = len(boston.target)\n",
    "X = boston.data\n",
    "y = boston.target"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Step 1 Average"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the average y is : 22.532806324110677\n"
     ]
    }
   ],
   "source": [
    "average_y=np.average(y)\n",
    "print(f'the average y is : {average_y}')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Step 2 For Loop"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "loss is 42716.29541501977\n",
      "new_loss is 36079.013132872846\n"
     ]
    }
   ],
   "source": [
    "#Firstly let's explore\n",
    "residuals0=boston.target - average_y\n",
    "loss0=np.sum(residuals0 ** 2)\n",
    "print(f'loss is {loss0}')\n",
    "tree0 = DecisionTreeRegressor(max_depth=3)\n",
    "tree0.fit(boston.data, residuals0)\n",
    "new_residuals=average_y+0.1*tree0.predict(boston.data)-boston.target\n",
    "new_loss=np.sum(new_residuals ** 2)\n",
    "print(f'new_loss is {new_loss}')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "#now let's get started\n",
    "learning_rate=0.1\n",
    "loss = [0] * 101\n",
    "residuals = np.zeros([101,n_samples])\n",
    "predictoin = np.zeros([101,n_samples])\n",
    "#calculation\n",
    "predictoin[0] = [average_y] * n_samples\n",
    "residuals[0] = y - predictoin[0]\n",
    "loss[0] = np.sum(residuals[0] ** 2)\n",
    "trees = []\n",
    "\n",
    "for i in range(100):\n",
    "    tree = DecisionTreeRegressor(max_depth=3)\n",
    "    tree.fit(X,residuals[i])\n",
    "    trees.append(tree)\n",
    "    #next prediction, residual\n",
    "    predictoin[i+1]=predictoin[i]+learning_rate * tree.predict(X)\n",
    "    residuals[i+1]=y-predictoin[i+1]\n",
    "    loss[i+1] = np.sum(residuals[i+1] ** 2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x1da8996ccc0>]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYcAAAD8CAYAAACcjGjIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAHs9JREFUeJzt3XuYXHWd5/H3t6q6q6/pTvqSpLtDOkAuIHKNGERHxQGDNxgXZuAZhfVhNs84+Izj6s7A7MUdR57RnV0vOIrLCis4rojoSFZRzHBRWbklcg0BEgIh93RunaQ73dVV9d0/zq9D0Zf0Jd1d3XU+r+epp+r8zq+qvuc5ST75nd85p8zdERERKZQodgEiIjL9KBxERGQQhYOIiAyicBARkUEUDiIiMojCQUREBlE4iIjIIAoHEREZROEgIiKDpIpdwHg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ncQqHUf1mRCkwszKiYPi+u/8kNO/uH26G5z3Fqm8SXAh8xMxeIzpceBHRSKI+HH6A0tvf24Bt7v54WL6HKCxKeT//IfCqu3e4ex/wE+AdlPZ+7jfcfp20f9fiFA6x+M2IcKz9NmCDu3+lYNVq4Nrw+lrg3qmubbK4+43u3ubu7UT79UF3/1PgIeCK0K3UtnkXsNXMloam9wEvUML7mehw0gozqwp/zvu3uWT3c4Hh9utq4Jpw1tIKoLP/8NOJitVFcGb2AaL/Ufb/ZsRNRS5pwpnZO4HfAs/xxvH3vyWad7gbOInoL9mV7j5w0mvGM7P3AJ9z9w+Z2clEI4k5wFPAx9y9t5j1TSQzO5toAr4c2Ax8gug/fCW7n83s74A/ITor7yngz4iOsZfMfjazHwDvIbr76m7g88BPGWK/hpD8J6Kzm7qBT7j72gmpI07hICIioxOnw0oiIjJKCgcRERlE4SAiIoMoHEREZBCFg4iIDKJwEBGRQRQOIiIyiMJBREQG+f9iPEjErACpLgAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(loss)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Reference:\n",
    "    \n",
    "https://www.youtube.com/watch?v=2xudPOBz-vs&list=PLblh5JKOoLUICTaGLRoHQDuF_7q2GfuJF&index=45&t=0s\n",
    "\n",
    "This article is based on this video."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
